//
//  payChooseView.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/9/6.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "payChooseView.h"

@implementation payChooseView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self createTablivews];
    }
    return self;
}
-(void)createTablivews{
    UIView *maskingView = [[UIView alloc] init];
    [self addSubview:maskingView];
    maskingView.backgroundColor = [UIColor blackColor];
    maskingView.alpha = 0.5;
    [maskingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self);
        make.height.mas_equalTo(HEIGHT - scaleTopAndBottom(170));
    }];
    self.tablview = [[UITableView alloc] initWithFrame:CGRectMake(0, HEIGHT - scaleTopAndBottom(170), WIDTH, scaleTopAndBottom(170)) style:UITableViewStylePlain];
    [self addSubview:self.tablview];
    [self.tablview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self);
        make.top.equalTo(maskingView.mas_bottom);
    }];
    self.tablview.dataSource = self;
    self.tablview.delegate = self;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellId = @"cellId";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    cell.textLabel.text = self.dataArray[indexPath.row];
    cell.imageView.backgroundColor = [UIColor redColor];
    return cell;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] init];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitle:@"取消" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [view addSubview:button];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.equalTo(view);
    }];
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return scaleTopAndBottom(60.f);
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return scaleTopAndBottom(55.f);
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}
-(NSArray *)dataArray{
    if (_dataArray == nil) {
        _dataArray = @[@"微信支付",@"支付宝支付"];
    }
    return _dataArray;
}
@end
